import {Image, Text, View} from "@tarojs/components";
import './index.scss'


export default ({onChange=(()=>{}),count=0,detail={}}) => {

  const priceArr=((detail.goodsPrice||'')+'').split('.')

  return (
    <View className='goods-item flex-cc'>
      <Image className='c-1' src={detail.imageUrl}></Image>
      <View className='c-2'>
        <View className='r-1'>{detail.goodsName}</View>
        <View className='r-2'>
          <View className='i-1'>
            <Text>￥</Text>
            <Text className='i-1-1'>{priceArr[0]}</Text>
            {
              !priceArr[1]?'':<Text>.{priceArr[1]}</Text>
            }
            <Text className='i-1-2'>{detail.goodsPrice}</Text>
          </View>
          <View className={`i-2 flex-cc ${count ? '' : 'nodata'}`}>
            <Image src={require('@/images/common/cut.svg')} mode='aspectFill' className="i-2-1" onClick={()=>{onChange(detail.id,-1)}} />
            <View className='i-2-2'>{count}</View>
            <Image src={require('@/images/common/add.svg')} mode='aspectFill' className="i-2-3" onClick={()=>{onChange(detail.id,1)}} />
          </View>
        </View>
      </View>
    </View>
  )
}
